const express = require('express');
const app = express();
const path = require('path');

const apiRoutes = require('./api');
const db = require('./data');

const checkInstalled = (req, res, next) => {
    next()
}

app.use('/api',apiRoutes);
app.use(checkInstalled);

app.use(express.static(path.join(__dirname, './public')));

app.get('*',(req, res) => {
    res.sendFile(path.join(__dirname, './public/index.html'));
})

const port = process.env.PORT || 3000;
app.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});